package com.community.property.util;

import jakarta.annotation.PostConstruct;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;



@Component
@Slf4j
public class QueueCleaner {

    @Autowired
    private AmqpAdmin amqpAdmin;

    @PostConstruct
    public void cleanQueuesOnStartup() {
        try {
            amqpAdmin.purgeQueue("repair.queue", false);
            amqpAdmin.purgeQueue("repair.dlx.queue", false);
            log.info("MQ队列清理完成");
        } catch (Exception e) {
            log.warn("清理队列失败: {}", e.getMessage());
        }
    }
}